package com.dayu.web.controller.store;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dayu.common.annotation.Log;
import com.dayu.common.core.controller.BaseController;
import com.dayu.common.core.domain.AjaxResult;
import com.dayu.common.enums.BusinessType;
import com.dayu.store.domain.AppletClerkUser;
import com.dayu.store.service.IAppletClerkUserService;
import com.dayu.common.utils.poi.ExcelUtil;
import com.dayu.common.core.page.TableDataInfo;

/**
 * 店员用户Controller
 * 
 * @author HK
 * @date 2022-01-07
 */
@RestController
@RequestMapping("/store/clerk_user")
public class AppletClerkUserController extends BaseController
{
    @Autowired
    private IAppletClerkUserService appletClerkUserService;

    /**
     * 查询店员用户列表
     */
    @PreAuthorize("@ss.hasPermi('store:clerk_user:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletClerkUser appletClerkUser)
    {
        startPage();
        List<AppletClerkUser> list = appletClerkUserService.selectAppletClerkUserList(appletClerkUser);
        return getDataTable(list);
    }

    /**
     * 导出店员用户列表
     */
    @PreAuthorize("@ss.hasPermi('store:clerk_user:export')")
    @Log(title = "店员用户", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppletClerkUser appletClerkUser)
    {
        List<AppletClerkUser> list = appletClerkUserService.selectAppletClerkUserList(appletClerkUser);
        ExcelUtil<AppletClerkUser> util = new ExcelUtil<AppletClerkUser>(AppletClerkUser.class);
        return util.exportExcel(list, "clerk_user");
    }

    /**
     * 获取店员用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:clerk_user:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(appletClerkUserService.selectAppletClerkUserById(id));
    }

    /**
     * 新增店员用户
     */
    @PreAuthorize("@ss.hasPermi('store:clerk_user:add')")
    @Log(title = "店员用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletClerkUser appletClerkUser)
    {
        return toAjax(appletClerkUserService.insertAppletClerkUser(appletClerkUser));
    }

    /**
     * 修改店员用户
     */
    @PreAuthorize("@ss.hasPermi('store:clerk_user:edit')")
    @Log(title = "店员用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletClerkUser appletClerkUser)
    {
        return toAjax(appletClerkUserService.updateAppletClerkUser(appletClerkUser));
    }

    /**
     * 删除店员用户
     */
    @PreAuthorize("@ss.hasPermi('store:clerk_user:remove')")
    @Log(title = "店员用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletClerkUserService.deleteAppletClerkUserByIds(ids));
    }
}
